/**   
* @Title: ResultGenerator.java 
* @Package com.cet.CetAPIPlateForm.base.core 
* @Description: TODO() 
* @author StronyLee
* @date May 4, 2018 9:49:11 AM 
* @version V1.0   
*/
package com.idea.cery.springboot1.base.core;
/**
 * 响应结果生成工具
 */
public class ResultGenerator {
    private static final String DEFAULT_SUCCESS_MESSAGE = "SUCCESS";

    public static Result genSuccessResult() {
        return new Result()
                .setCode(ResultCode.SUCCESS)
                .setMessage(DEFAULT_SUCCESS_MESSAGE);
    }

    public static Result genSuccessResult(Object data) {
        return new Result()
                .setCode(ResultCode.SUCCESS)
                .setMessage(DEFAULT_SUCCESS_MESSAGE)
                .setData(data);
    }

    public static Result genFailResult(String message) {
        return new Result()
                .setCode(ResultCode.FAIL)
                .setMessage(message);
    }
    
    public static Result genUnauthorizedResult(String message) {
    	return new Result()
    			.setCode(ResultCode.UNAUTHORIZED)
    			.setMessage(message);
    }
}
